home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FFT / FFTR2A.ASM < prev    next >
Assembly Source File  |  1990-01-17  |  3KB  |  98 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ; Radix 2, In-Place, Decimation-In-Time FFT (smallest code size).
  6. ; Last Update 30 Sep 86   Version 1.1
  7. ;
  8. fftr2a   macro     points,data,coef
  9. fftr2a   ident     1,1
  10. ;
  11. ; Radix 2 Decimation in Time In-Place Fast Fourier Transform Routine
  12. ;
  13. ;    Complex input and output data
  14. ;        Real data in X memory
  15. ;        Imaginary data in Y memory
  16. ;    Normally ordered input data
  17. ;    Bit reversed output data
  18. ;        Coefficient lookup table
  19. ;        -Cosine values in X memory
  20. ;        -Sine values in Y memory
  21. ;
  22. ; Macro Call - fftr2a   points,data,coef
  23. ;
  24. ;        points     number of points (2-32768, power of 2)
  25. ;        data       start of data buffer
  26. ;        coef      start of sine/cosine table
  27. ;
  28. ; Alters Data ALU Registers
  29. ;        x1     x0  y1       y0
  30. ;        a2     a1  a0       a
  31. ;        b2     b1  b0       b
  32. ;
  33. ; Alters Address Registers
  34. ;        r0     n0  m0
  35. ;        r1     n1  m1
  36. ;               n2
  37. ;
  38. ;        r4     n4  m4
  39. ;        r5     n5  m5
  40. ;        r6     n6  m6
  41. ;
  42. ; Alters Program Control Registers
  43. ;        pc     sr
  44. ;
  45. ; Uses 6 locations on System Stack
  46. ;
  47. ; Latest Revision - September 30, 1986
  48. ;
  49.          move    #points/2,n0      ;initialize butterflies per group
  50.          move    #1,n2             ;initialize groups per pass
  51.          move    #points/4,n6      ;initialize C pointer offset
  52.          move    #-1,m0            ;initialize A and B address modifiers
  53.          move    m0,m1             ;for linear addressing
  54.          move    m0,m4
  55.          move    m0,m5
  56.          move    #0,m6             ;initialize C address modifier for
  57.                                    ;reverse carry (bit-reversed) addressing
  58. ;
  59. ; Perform all FFT passes with triple nested DO loop
  60. ;
  61.          do      #@cvi(@log(points)/@log(2)+0.5),_end_pass
  62.          move    #data,r0        ;initialize A input pointer
  63.          move    r0,r4           ;initialize A output pointer
  64.          lua     (r0)+n0,r1      ;initialize B input pointer
  65.          move    #coef,r6        ;initialize C input pointer
  66.          lua     (r1)-,r5        ;initialize B output pointer
  67.          move    n0,n1           ;initialize pointer offsets
  68.          move    n0,n4
  69.          move    n0,n5
  70.  
  71.          do      n2,_end_grp
  72.          move    x:(r1),x1  y:(r6),y0        ;lookup -sine and 
  73.                                              ; -cosine values
  74.          move    x:(r5),a   y:(r0),b         ;preload data
  75.          move    x:(r6)+n6,x0                ;update C pointer
  76.  
  77.  
  78.          do      n0,_end_bfy
  79.          mac     x1,y0,b    y:(r1)+,y1       ;Radix 2 DIT
  80.                                              ;butterfly kernel
  81.          macr    -x0,y1,b   a,x:(r5)+    y:(r0),a
  82.          subl    b,a        x:(r0),b     b,y:(r4)
  83.          mac     -x1,x0,b   x:(r0)+,a  a,y:(r5)
  84.          macr    -y1,y0,b   x:(r1),x1
  85.          subl    b,a        b,x:(r4)+  y:(r0),b
  86. _end_bfy
  87.          move    a,x:(r5)+n5    y:(r1)+n1,y1   ;update A and B pointers
  88.          move    x:(r0)+n0,x1   y:(r4)+n4,y1
  89. _end_grp
  90.          move    n0,b1
  91.          lsr     b   n2,a1     ;divide butterflies per group by two
  92.          lsl     a   b1,n0     ;multiply groups per pass by two
  93.          move    a1,n2
  94. _end_pass
  95.          endm
  96.